package br.ufpa.cbcc2007.dikemon;

import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

import br.ufpa.cbcc2007.dikemon.engine.Engine;
import br.ufpa.cbcc2007.dikemon.exception.MapNotFoundException;
import br.ufpa.cbcc2007.dikemon.map.MapScene;

public class Main extends MIDlet {

	private Display display;
	private Engine gameCanvas;

	public Main() {
		display = Display.getDisplay(this);
		try {
			gameCanvas = new Engine(new MapScene(),false);
			MapScene.getMapScene().setActualMap("map2");
		} catch (MapNotFoundException e) {
			e.printStackTrace();
		}
	}

	protected void destroyApp(boolean unconditional)
			throws MIDletStateChangeException {

	}   

	protected void pauseApp() {

	}

	protected void startApp() throws MIDletStateChangeException {
		display.setCurrent(gameCanvas);
		new Thread(gameCanvas).start();
	}
	

	public void exitMIDlet() {
		try {
			destroyApp(false);
		} catch (MIDletStateChangeException e) {
		}
		notifyDestroyed();
	}

}
